package SortTable;

//冒泡排序
public class BubbleSort {
    public static void sort(int[] arr){
        int len=arr.length-1;
        for (int i=len;i>=1;i--){
            for (int j=0;j<=i-1;j++){
                if (arr[j+1]<arr[j]){
                    int temp=arr[j+1];
                    arr[j+1]=arr[j];
                    arr[j]=temp;
                }
            }
        }
    }
    public static void main(String[] args) {
        int arr[]={4,5,3,6,9,8,7,6,2};
        sort(arr);
        for (int i=0;i<=arr.length-1;i++){
            System.out.print(arr[i]+" ");
        }

    }
}
